In this article, Iwill show you how to know which Radio button selected using JQuery. You can getradio button selected value by group name of radio button using checkedproperty.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('input').on('change', function () {
alert($('input[name=Countries]:checked').val());
});
});
</script>
<form id="Form1">
Select your Country:
<br />
<input type="radio" name="Countries" value="India" />
India
<br />
<input type="radio" name="Countries" value="Pakistan" />
Pakistan
<br />
<input type="radio" name="Countries" value="Bangladesh" />
Bangladesh
<br />
</form>
Description:
In above example, ifthe user selects the Country from the country List you can get the selectedcountry by group name (Countries) using checked property.
Output:
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article